package cn.itcast.a_hello;

import java.util.Date;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.junit.Test;

public class App {

	@Test
	public void testHello() throws Exception {
		Employee emp = new Employee();
		emp.setEmpId(1);//id 会自增啊
		emp.setEmpName("北京舒望啊");
		emp.setWorkDate(new Date());
		
		Configuration config = new Configuration();
		config.configure();//加载配置文件和映射文件
		SessionFactory sf = config.buildSessionFactory();
		Session session = sf.openSession();
		Transaction tx = session.beginTransaction();
		session.save(emp);
		tx.commit();
		session.close();
		sf.close();
	}
}
